<?php
session_start();

include "webmaster_connect.php";

$page_permission = 2;

include "webmaster_check_login.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
body {
	background-image: url(../images/wood.jpg);
	background-repeat: repeat-x;
	margin: 0px;
	background-position: left top;
	background-attachment: fixed;
	background-color: #000000;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
}
</style>
<link href="../css/webmaster_edit_products.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div id="page_container">

<?php 

include "../admin_files/webmaster_header.php";
include "../admin_files/webmaster_navigation.php" 

?>

<div id="content_container">


<h1>Find products:</h1>

<form id="product_search" action="webmaster_find_products.php" method="post" name="product_search">

<input name="search_id" type="text" placeholder="Product id" />

<input name="refresh_products" type="submit" value="Search" />

</form>

<br />

<form id="product_search" action="webmaster_find_products.php" method="post" name="product_search">

<input name="search_name" type="text" placeholder="Product name" />

<input name="refresh_products" type="submit" value="Search" />

</form>

<table width="970px" border="0" cellpadding="3">

<tr>
    <th class="header" scope="col"></th>
    <th class="header" scope="col">Product ID</th>
    <th class="header" scope="col">Product Type</th>
    <th class="header" scope="col">Product Catagory</th>
	<th class="header" scope="col">Prodyct Sub Catagory</th>
    <th class="header" scope="col">Product Name</th>
	<th class="header" scope="col">Product Cost</th>
    <th class="header" scope="col">Product Status</th>
  </tr>

<?php 

$search_id = $_POST['search_id'];


if(isset($_POST['search_id'])) //If status is posted then do below checks

{
	
		$search_id = $_POST['search_id'];
	
		$query = "SELECT * FROM saddles WHERE product_id = '$search_id'";
		
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result))
		{
	
		echo '

	<tr id="'.$row['product_status'].'">
    
  		<th>
		<form action="webmaster_amend_products.php" method="post" name="edit_product">
		<input name="product_row_id" type="hidden" value="'.$row['id'].'" />
		<input name="edit_product" type="submit" value="Edit" />
		</form>
		</th>
	
  		<th>'.$row['product_id'].'</th>
  		<th>'.$row['product_type'].'</th>
  	  	<th>'.$row['product_catagory'].'</th>
		<th>'.$row['product_sub_catagory'].'</th>
  		<th>'.$row['product_name'].'</th>
		<th>£'.$row['product_cost'].'</th>
		<th>'.$row['product_status'].'</th>
  	</tr>';
	
}
		
}




if(isset($_POST['search_name'])) //If status is posted then do below checks

{
	
		$query = "SELECT * FROM saddles";

		$query .= ' WHERE product_name LIKE "%'.$_POST['search_name'].'%"';
		
		
		
		
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result))
		{
	
		echo '

	<tr id="'.$row['product_status'].'">
    
  		<th>
		<form action="webmaster_amend_products.php" method="post" name="edit_product">
		<input name="product_row_id" type="hidden" value="'.$row['id'].'" />
		<input name="edit_product" type="submit" value="Edit" />
		</form>
		</th>
	
  		<th>'.$row['product_id'].'</th>
  		<th>'.$row['product_type'].'</th>
  	  	<th>'.$row['product_catagory'].'</th>
		<th>'.$row['product_sub_catagory'].'</th>
  		<th>'.$row['product_name'].'</th>
		<th>£'.$row['product_cost'].'</th>
		<th>'.$row['product_status'].'</th>
  	</tr>';
	
}
		
}

?>

</table>

</div>
<!--login_container-->

</div> 
<!--page_container-->

</body>
</html>

